package se.webbzon.boltzmann.game.event;

import se.webbzon.boltzmann.game.sequence.Sequence;
import se.webbzon.oschi01.worldarea.WorldArea;
import se.webbzon.oschi01.worldobject.WorldObject;
import se.webbzon.oschi01.worldobject.WorldStaticObject;

public class TeleportToEvent extends AbstractTargetEvent {

	// The binding of this event
	private final WorldObject binding;
	
	/*============================================================
	Constructors
	============================================================*/
	
	public TeleportToEvent(Sequence sequence, WorldObject binding, String[] arguments) {
		super(sequence, arguments);
		this.binding = binding;
	}
	
	/*============================================================
	Public Methods
	============================================================*/

	@Override protected void onBegin(WorldArea world) {
		WorldObject target = getTarget();
		if (	binding instanceof WorldStaticObject &&
				target instanceof WorldStaticObject) {
			WorldStaticObject wso = (WorldStaticObject) binding;
			WorldStaticObject t = (WorldStaticObject) target;
			wso.setPosition(t.getX(), t.getY(), t.getZ());
		}
		end();
	}

	@Override protected void onEnd() {};

}
